{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 样例表\n",
    "```MYSQL\n",
    "CREATE DATABASE crash_course;\n",
    "USE crash_course;\n",
    "SOURCE create.sql   #完整路径\n",
    "SOURCE populate.sql\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 检索数据\n",
    "`SELECT`语句\n",
    "```MYSQL\n",
    "检索单列\n",
    "SELECT prod_name\n",
    "FROM products;\n",
    "\n",
    "检索多个列\n",
    "SELECT prod_id, prod_name, prod_price\n",
    "FROM products;\n",
    "\n",
    "检索所有列\n",
    "SELECT *\n",
    "FROM products;\n",
    "\n",
    "检索出不同行\n",
    "SELECT DISTINCT vend_id\n",
    "FROM products;\n",
    "\n",
    "SELECT DISTINCT vend_id, prod_price\n",
    "FROM products;   #两列都相同的行，检索不出\n",
    "\n",
    "限制结果\n",
    "SELECT prod_name\n",
    "FROM products\n",
    "LIMIT 5;  #限制行数\n",
    "\n",
    "SELECT prod_name\n",
    "FROM products\n",
    "LIMIT 5,3;   #从行号5开始，检索出3行，第一行行号为0\n",
    "\n",
    "完全限定\n",
    "SELECT products.prod_id\n",
    "FROM products; #完全限定列\n",
    "SELECT products.prod_id\n",
    "FROM crash_course.products; #完全限定列 及 表\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
